package chapter.second.item7;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;

import org.perf4j.StopWatch;

import com.alibaba.fastjson.JSON;

public class Foo7 implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String getName() {
		return name;
	}

	private final String name = "fff";
	
	private Guardian finalizerGuardian = new Guardian();
	
	protected class Guardian{
		@Override
		protected void finalize() throws Throwable {
			f();
		}
	}
	
	protected void f() throws Throwable{
		System.out.println(JSON.toJSONString(this));
		this.finalize();
		System.out.println("终结匿名类对象");
	}
	
	public static void main(String[] args) throws Throwable {
		Foo7 f = new Foo7();
		System.out.println(f.name);
		f.finalizerGuardian.finalize();
		System.out.println(f.name);
	}
}
